Python Data Science by Axel Ross & Axel Ross
XLS
If you want to read data from an Excel file, you also need a package called xlrd:
>>>
d=pd.read_excel('Data/Student_Weight_Status_Category_Reporting_Results__Beginning_2010.xls')
Writing to an Excel file requires the xlwt package:
>>> df.to_excel('sample_data.xls')
JSON
We can use the json package in Python to read from JSON files and use the following commands to read from them:
>>> import json
>>> json_data =
Open('Data/Student_Weight_Status_Category_Reporting_Re sults__Beginning_2010.json')
>>> data = json.load(json_data)
>>> json_data.close()
In this, a connection to the file is opened using the open() function. Data is loaded into Python with the json.load() function and the connection is closed using json_data.close().
There is also a function in pandas that lets us read JSON files with pd.read_json().